package com.siwei.mes.handler.service.impl;

import com.siwei.mes.entity.experiment.Experiment;
import com.siwei.mes.entity.experiment.ExperimentDetail;
import com.siwei.mes.enums.TestProjectEnum;
import com.siwei.mes.handler.service.ExperimentFactoryService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;

import java.util.List;

/**
 * 试验台账抽象类
 *
 * @Description: 试验台账抽象类
 * @Version: 1.0
 * @author: chenmaolin
 * @date: 2024/2/21 22:01
 */
@Slf4j
public abstract class AbstractExperimentFactoryServiceImpl implements ExperimentFactoryService {

    @Override
    public void checkIsBatchFinish(Experiment experiment) {

    }

    @Override
    public String checkIsMustToExperimentDetail(List<ExperimentDetail> detailList) {
        return null;
    }


    /**
     * 校验图片是否为空
     *
     * @param objImg
     * @return
     */
    public String checkIsUploadImg(String objImg) {
        if (StringUtils.isBlank(objImg) || "null".equals(objImg)) {
            return "存在必检项未上传检测图片，请先上传检测图片！";
        }
        return null;
    }

    /**
     * 校验图片是否为空
     *
     * @param objImg
     * @param testProjectCode
     * @return
     */
    public String checkIsUploadImg(String objImg, String testProjectCode) {
        TestProjectEnum testProjectEnum = TestProjectEnum.getName(testProjectCode);
        if (testProjectEnum == null) {
            log.info("暂未配置该类型的必填校验，类型：" + testProjectCode);
            return null;
        }
        if (StringUtils.isBlank(objImg) || "null".equals(objImg)) {
            return "存在必检项(" + testProjectEnum.getName() + ")未上传检测图片，请先上传检测图片！";
        }
        return null;
    }
}
